// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  var id = event.id
  var detailAddress = event.detailAddress
  var areaRegion = event.areaRegion
  var date = event.date
  var medicineWay = event.medicineWay
  var pesticideType = event.pesticideType
  try {
    return await db.collection('Order').doc(id).update({
      data: {
        detailAddress: detailAddress,
        areaRegion: areaRegion,
        date: date,
        medicineWay: medicineWay,
        pesticideType: pesticideType
      }
    })
  } catch (e) {
    console.log(e)
  }
}